package sapling.utils;


import java.awt.geom.Point2D;
import java.text.DecimalFormat;
import java.util.List;

/**
 * Created by Administrator on 2017/8/1.
 */
public class MathUtil {
    public static int getInt(int c, int bc) {
        DecimalFormat df = new DecimalFormat("0.00");
        double result = (double) c / bc;
        int retresult = 100;
        if (result < 1) {
            String num = df.format(result);
            retresult = Integer.parseInt(num.substring(num.length() - 2, num.length()));
        }
        return retresult;
    }
    public static boolean checkWithJdkGeneralPath(Point2D.Double point, List<Point2D.Double> polygon) {
        java.awt.geom.GeneralPath p = new java.awt.geom.GeneralPath();
        Point2D.Double first = polygon.get(0);
        p.moveTo(first.x, first.y);
        polygon.remove(0);
        for (Point2D.Double d : polygon) {
            p.lineTo(d.x, d.y);
        }
        p.lineTo(first.x, first.y);
        p.closePath();
        return p.contains(point);
    }
}
